<template>
  <div>
    <el-dialog
      title="制程检验处理"
      append-to-body
      destroy-on-close
      :close-on-press-escape="false"
      fullscreen
      v-if="visible"
      :modal-append-to-body="true"
      :close-on-click-modal="false"
      :visible.sync="visible"
      @close="handleEditReset"
    >
      <div class="dialog-content">
        <div class="titleIcon">
          <i class="el-icon-vertical-bar avue-group__icon"></i>
          <h4>基本信息</h4>
        </div>
        <avue-form ref="basicInfoForm" v-model="basicInfoForm" :option="basicInfoOption"></avue-form>
        <div class="title-result">
          <div class="title">
            <i class="el-icon-vertical-bar avue-group__icon"></i>
            <h4>检验结果记录</h4>
          </div>
          <div class="reslut-btn-group">
            <el-button type="primary" size="small" @click="handleDownloadTempelate">检验模板下载</el-button>
            <el-button type="primary" size="small" @click="handleGoToHistoryQuery">历史检验记录查询</el-button>
          </div>
        </div>
        <avue-form
          ref="inspectionResultsRecordForm"
          v-model="basicInfoForm"
          :option="inspectionResultsRecordOption"
          :upload-after="uploadAfter"
          :upload-delete="uploadDelete"
          :upload-preview="uploadPreview"
        >
        </avue-form>
        <div class="titleIcon">
          <i class="el-icon-vertical-bar avue-group__icon"></i>
          <h4>异常记录</h4>
        </div>
        <avue-crud
          ref="bnormalRecordCrud"
          v-model="qmsInspectionExceptionVoListForm"
          :option="abnormalRecordOption"
          :data="basicInfoForm.qmsInspectionExceptionVoList"
          :upload-after="tableUploadAfter"
          :upload-delete="tableUploadDelete"
          :before-open="beforeOpen"
          @row-update="rowUpdate"
          @row-save="rowSave"
          @row-del="rowDel"
        >
        </avue-crud>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" type="success" @click="handleSaveDraft"><i class="el-icon-circle-plus-outline"></i><span>保存草稿</span></el-button>
        <el-button size="small" type="primary" @click="handleSubmit"><i class="el-icon-circle-plus-outline"></i><span>提 交</span></el-button>
        <el-button size="small" icon="el-icon-delete" @click="handleEditReset">取消</el-button>
      </span>
    </el-dialog>
    <!-- 检验模板下载 -->
    <el-dialog title="检验模板下载" :visible.sync="downLoadVisible" width="30%" append-to-body destroy-on-close>
      <h4>产品检验模版：</h4>
      <div class="download-box">
        <div class="dowload-item" v-for="(file, index) of templateList" :key="index" @click="downLoad(file)">
          <span>{{ file.originalName }}</span>
        </div>
      </div>
    </el-dialog>
    <el-dialog
      ref="dialog"
      title="查看PDF"
      append-to-body
      :visible.sync="showEsopDialog"
      :full-screen="fullScreen"
      :class="[fullScreen ? 'fullscreen' : 'no_fullScreen']"
      :close-on-click-modal="false"
      @close="fullScreen = false"
    >
      <iframe ref="pdf" :src="pdfUrl" width="100%" :height="iframeHeight"></iframe>
      <div slot="title" class="dialog-title">
        <span class="title">查看PDF</span>
        <span class="el-dialog__close fullscreen-icon" @click="fullScreen = !fullScreen">
          <i class="el-icon-full-screen"></i>
        </span>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="showEsopDialog = false"><i class="el-icon-circle-close"></i><span>取 消</span></el-button>
      </span>
    </el-dialog>
    <doc-preview :url="fileUrl" :visiable.sync="previewVisible" :file-type="fileType"></doc-preview>

    <!--公用模态弹框-->
    <common-modal-template ref="commonModalTemplate" :option="tableOption" @getSelectedRows="getSelectedRows"> </common-modal-template>
  </div>
</template>

<script>
import { getDetail } from '@/api/quality/beforePackingWaitInspect';
import { getMainTypeList, getSubTypeList } from '@/api/quality/firstArticleInspection';
import { getQmsTemplateFile } from '@/api/resource/attach';
import { handle } from '@/api/quality/beforePackingWaitInspect';
import commonModalTemplate from '@/components/common-modal-template/common-modal-template';
import userTableConfig from '@/components/user-table-config';
import exportExcel from '@/components/export-excel';
import { exprot, getExprot } from '@/api/repair/failureconfig';
import DocPreview from '@/components/filePreview/docPreview';
import { downLoad } from '@/api/resource/attach';
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  components: {
    commonModalTemplate,
    DocPreview
  },
  name: 'handleProcessInspect',
  data() {
    return {
      modelName: '',
      templateList: [],
      tableOption: {},
      mainTypeList: [],
      subTypeList: [],
      downLoadVisible: false,
      qmsInspectionAttachmentList: [],
      isInitialized: false,
      fileType: '',
      fileUrl: '',
      pdfUrl: '',
      previewVisible: false,
      showEsopDialog: false,
      fullScreen: '',
      basicInfoForm: {},
      basicInfoOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 150,
        column: [
          {
            label: '巡检类型',
            prop: 'documentSubType',
            type: 'select',
            span: 8,
            props: {
              label: 'dictValue',
              value: 'dictKey'
            },
            disabled: true,
            dicUrl: '/api/blade-system/dict/dictionary?code=ipqc_type'
          },
          {
            label: '车间',
            prop: 'workshopId',
            filterable: true,
            disabled: true,
            type: 'select',
            span: 8,
            searchOrder: 5,
            search: true,
            dicUrl: '/api/mes-admin/workshop/key-value',
            props: {
              label: 'workshopName',
              value: 'workshopId'
            }
          },
          {
            label: '产线',
            disabled: true,
            span: 8,
            prop: 'lineName'
          },
          // {
          //   label: '工段',
          //   disabled: true,
          //   span: 8,
          //   prop: 'sectionNames'
          // },
          {
            label: '生产工单',
            prop: 'sourceNo',
            span: 8,
            disabled: true
          },

          {
            label: '物料编码',
            prop: 'partNo',
            span: 8,
            disabled: true
          },
          {
            label: '物料名称',
            prop: 'partName',
            span: 8,
            disabled: true
          },
          {
            label: '产品型号',
            prop: 'partModel',
            span: 8,
            disabled: true
          },
          {
            label: '工单数量',
            prop: 'workOrderQuantity',
            span: 8,
            disabled: true
          },
          {
            label: '巡检时段',
            prop: 'ipqcTimeframe',
            span: 8,
            disabled: true
          },
          {
            label: '报检时间',
            prop: 'createTime',
            span: 8,
            disabled: true
          },
          {
            label: '是否加急',
            prop: 'isUrgent',
            span: 8,
            type: 'select',
            dicData: [
              {
                label: '否',
                value: false
              },
              {
                label: '是',
                value: true
              }
            ],
            disabled: true
          },
          {
            label: '检验人员',
            prop: 'examineByName',
            type: 'search',
            span: 8,
            disabled: true,
            appendClick: () => {
              this.openUserCommonModal();
            }
          }
        ]
      },
      inspectionResultsRecordForm: {},
      qmsInspectionExceptionVoListForm: {},
      inspectionResultsRecordOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 150,
        column: [
          {
            label: '检验结果',
            prop: 'examineResult',
            span: 24,
            type: 'select',
            dicData: [
              { label: 'OK', value: 'OK' },
              { label: 'NG', value: 'NG' }
            ],
            rules: [
              {
                required: true,
                message: '请选择 检验结果',
                trigger: 'blur'
              }
            ],
            row: true
          },
          {
            label: '上传检验报告',
            prop: 'attachments',
            type: 'upload',
            dataType: 'object',
            multiple: true,
            row: true,
            span: 24,
            propsHttp: {
              url: 'link',
              name: 'originalName',
              res: 'data'
            },
            action: '/api/blade-resource/oss/endpoint/put-file-attach',
            rules: [
              {
                required: true,
                message: '请上传检验报告',
                trigger: 'blur'
              }
            ]
          },
          {
            label: '备注',
            prop: 'remark',
            type: 'textarea',
            row: true,
            span: 24,
            maxRows: 3,
            minRows: 3
          }
        ]
      },
      abnormalRecordData: [],
      abnormalRecordOption: {
        height: '300',
        calcHeight: 30,
        tip: false,
        border: true,
        index: true,
        indexLabel: '序号',
        selection: true,
        addBtn: true,
        addBtnText: '新增异常记录',
        editBtn: true,
        delBtn: true,
        viewBtn: true,
        menu: true,
        refreshBtn: false,
        columnBtn: false,
        labelWidth: 150,
        column: [
          {
            label: '不良现象',
            prop: 'ngFailureName',
            addDisplay: false,
            editDisplay: false
          },
          {
            label: '不良原因（大类）',
            prop: 'ngMainCauseName',
            addDisplay: false,
            editDisplay: false
          },
          {
            label: '不良原因（小类）',
            prop: 'ngSubCauseName',
            addDisplay: false,
            editDisplay: false
          },
          {
            label: '不良代码',
            prop: 'failureCode',
            type: 'search',
            hide: true,
            viewDisplay: false,
            appendClick: () => {
              this.openFailureCommonModal();
            },
            rules: [
              {
                required: true,
                message: '请选择不良代码',
                trigger: 'blur'
              }
            ],
            disabled: true
          },
          {
            label: '不良原因（大类）',
            prop: 'mainType',
            type: 'select',
            hide: true,
            viewDisplay: false,
            dicData: [],
            rules: [
              {
                required: true,
                message: '请选择不良原因（大类）',
                trigger: 'blur'
              }
            ],
            change: (val) => {
              if (val.value) {
                this.getSubTypeList(val.value);
                if (this.qmsInspectionExceptionVoListForm.subType.length && this.isInitialized) {
                  this.qmsInspectionExceptionVoListForm.subType = [];
                }
              } else {
                const column = this.findObject(this.abnormalRecordOption.column, 'subType');
                column.dicData = [];
                this.qmsInspectionExceptionVoListForm.subName = '';
              }
              this.isInitialized = true;
            }
          },
          {
            label: '不良原因（小类）',
            prop: 'subType',
            type: 'select',
            multiple: true,
            hide: true,
            viewDisplay: false,
            dicData: []
          },
          {
            label: '不良说明',
            prop: 'faultDescription',
            type: 'textarea',
            span: 24,
            maxRows: 3,
            minRows: 3
          },
          {
            label: '改善措施',
            prop: 'improvementMeasure',
            type: 'textarea',
            span: 24,
            maxRows: 3,
            minRows: 3,
            rules: [
              {
                required: true,
                message: '请选择改善措施',
                trigger: 'blur'
              }
            ]
          },
          {
            label: '备注',
            prop: 'remark',
            type: 'textarea',
            span: 24,
            maxRows: 3,
            minRows: 3
          },
          {
            label: '附件',
            prop: 'img',
            type: 'upload',
            dataType: 'string',
            listType: 'picture-card',
            addDisplay: false,
            editDisplay: false,
            span: 24,
            hide: true
          },
          {
            label: '附件',
            prop: 'attachments',
            type: 'upload',
            dataType: 'object',
            loadText: '图片上传中，请稍等',
            row: true,
            span: 24,
            listType: 'picture-card',
            propsHttp: {
              url: 'link',
              name: 'attachId',
              res: 'data'
            },
            hide: true,
            viewDisplay: false,
            accept: 'image/png, image/jpeg, image/jpg',
            tip: '只能上传png/jpeg/jpg文件',
            action: '/api/blade-resource/oss/endpoint/put-file-attach'
          }
        ]
      },
      inspectionPictureList: []
    };
  },
  computed: {
    iframeHeight() {
      const docHeight = document.documentElement.clientHeight;
      const iframeHeight = docHeight - 188 + 'px';
      return this.fullScreen ? iframeHeight : '600px';
    }
  },
  methods: {
    async getData(id) {
      try {
        const res = await getDetail(id);
        await this.getMaintype();
        const data = res.data.data;
        this.basicInfoForm = data;
        this.basicInfoForm.examineBy = this.basicInfoForm.examineBy ? this.basicInfoForm.examineBy : JSON.parse(localStorage.getItem('saber-userInfo')).content.user_id;
        this.basicInfoForm.examineByName = this.basicInfoForm.examineByName
          ? this.basicInfoForm.examineByName
          : JSON.parse(localStorage.getItem('saber-userInfo')).content.user_name;
        // this.basicInfoForm.attachments = data.qmsInspectionAttachmentList;
        this.basicInfoForm.attachments =
          (data.qmsInspectionAttachmentList.length &&
            data.qmsInspectionAttachmentList.map((item) => ({
              value: item.link,
              label: item.attachmentName
            }))) ||
          [];
      } catch (e) {
      } finally {
      }
    },
    getSubTypeList(id) {
      const column = this.findObject(this.abnormalRecordOption.column, 'subType');

      getSubTypeList(id).then(
        (res) => {
          this.subTypeList = this._get(res, 'data.data.subList', []);
          column.dicData = this._get(res, 'data.data.subList', []);
          column.dicData = this._map(column.dicData, (item) => {
            return {
              label: item.name,
              value: item.id
            };
          });
        },
        (error) => {
          column.dicData = [];
        }
      );
    },
    getMaintype() {
      const column = this.findObject(this.abnormalRecordOption.column, 'mainType');
      getMainTypeList().then(
        (res) => {
          this.mainTypeList = this._get(res, 'data.data', []);
          column.dicData = this._get(res, 'data.data', []);
          column.dicData = this._map(column.dicData, (item) => {
            return {
              label: item.name,
              value: item.id
            };
          });
        },
        (error) => {
          column.dicData = [];
        }
      );
    },
    handleEditReset() {
      this.inspectionPictureList = [];
      this.$emit('update:visible', false);
      this.$emit('closeDialog');
    },
    handleSaveDraft() {
      this.$refs.inspectionResultsRecordForm.validate((valid, done) => {
        if (valid) {
          const form = this._cloneDeep(this.basicInfoForm);
          let params = {
            ...form,
            status: 4
          };
          handle(params).then(
            (res) => {
              this.$message.success(res.data.msg);
              this.qmslnspectionAttachmentList = [];
              this.$emit('update:visible', false);
              this.$emit('closeDialog');
              done();
            },
            (error) => {
              done();
            }
          );
        }
      });
    },
    handleSubmit() {
      this.$refs.inspectionResultsRecordForm.validate((valid, done) => {
        if (valid) {
          const form = this._cloneDeep(this.basicInfoForm);
          let params = {
            ...form,
            status: 2
          };
          handle(params).then(
            (res) => {
              this.$message.success(res.data.msg);
              this.qmsInspectionAttachmentList = [];
              this.$emit('update:visible', false);
              this.$emit('closeDialog');
              done();
            },
            (error) => {
              done();
            }
          );
        }
      });
    },
    uploadAfter(res, done, loading, column) {
      if (res instanceof Error) {
        this.$message.error('上传失败,请联系管理员');
      } else {
        const obj = {
          attachmentName: res.originalName,
          link: res.link,
          attachmentId: res.attachId
        };
        this.basicInfoForm.qmsInspectionAttachmentList.push(obj);
      }
      done();
    },
    uploadDelete(file, column) {
      const deleteIndex = Number(file.uid);
      this.basicInfoForm.qmsInspectionAttachmentList.splice(deleteIndex, 1);
    },
    tableUploadAfter(res, done, loading, column) {
      if (res instanceof Error) {
        this.$message.error('上传失败,请联系管理员');
      } else {
        const obj = {
          attachmentName: res.originalName,
          link: res.link,
          attachmentId: res.attachId
        };
        this.qmsInspectionAttachmentList.push(obj);
      }
      done();
    },
    tableUploadDelete(file, column) {
      const deleteIndex = Number(file.uid);
      this.qmsInspectionAttachmentList.splice(deleteIndex, 1);
    },
    beforeOpen(done, type) {
      this.isInitialized = false;
      if (type === 'view') {
        try {
          this.qmsInspectionExceptionVoListForm.img = this.qmsInspectionExceptionVoListForm.qmsInspectionAttachmentList.map((item) => item.link).join(',');
        } catch (e) {
          this.qmsInspectionExceptionVoListForm.img = '';
        }
      } else if (type === 'edit') {
        try {
          this.qmsInspectionExceptionVoListForm.attachments = this.qmsInspectionExceptionVoListForm.qmsInspectionAttachmentList.map((item) => item.link).join(',');
        } catch (e) {
          this.qmsInspectionExceptionVoListForm.attachments = '';
        }
        let obj = {};
        const subArray = [];
        const subName = [];
        this.qmsInspectionExceptionVoListForm.qmsInspectionExceptionDetailList.forEach((item) => {
          if (item.dictType === 'FAILURE') {
            obj.failureName = item.dictName;
            obj.failureId = item.dictId;
            obj.failureCode = item.dictCode;
          } else if (item.dictType === 'CAUSE' && item.subType === 'MAIN') {
            obj.mainType = item.dictId;
          } else {
            subArray.push(item.dictId);
            subName.push(item.dictName);
          }
        });
        obj.subType = subArray;
        obj.$subType = subName.join('|');
        this.qmsInspectionExceptionVoListForm = Object.assign(this.qmsInspectionExceptionVoListForm, obj);
      }
      done();
    },
    handleGoToHistoryQuery() {
      this.$emit('update:visible', false);
      this.$router.push({
        path: '/quality/refactor/processInspectionRecord',
        query: {
          partNo: encodeURIComponent(this.basicInfoForm.partNo)
        }
      });
    },
    handleDownloadTempelate() {
      this.getAttachTemplate();
      this.downLoadVisible = true;
      // this.tempateList = ['来料检验A001的检验模版.xlxs', '来料检验A001的检验模版2.xlxs', '来料检验A001的检验模版3.xlxs'];
    },
    getAttachTemplate() {
      getQmsTemplateFile({
        attachType: 'QMS',
        attachSubType: 'IPQC'
      }).then((res) => {
        let data = res.data.data;
        this.templateList = data || [];
      });
    },
    async downLoad(file) {
      const data = {
        originalName: file.originalName,
        attachType: 'QMS'
      };
      try {
        const res = await exprot({ data });
        const blob = new Blob([res.data]);
        const fileName = file.originalName;
        const link = document.createElement('a');
        link.download = fileName;
        link.style.display = 'none';
        link.href = URL.createObjectURL(blob);
        document.body.append(link);
        link.click();
        URL.revokeObjectURL(link.href);
        document.body.removeChild(link);
      } catch (e) {
        const failMsg = await this.blobToJson(e.data);
        this.$message.error(failMsg.msg);
      }
    },
    getFileType(url) {
      // 从URL中提取文件名
      const filename = url.split('/').pop();
      // 提取文件名的扩展名
      const fileExtension = filename.split('.').pop();
      return fileExtension;
    },
    handleFullScreen() {
      this.fullScreen = !this.fullScreen;
    },

    uploadPreview(file, column, done) {
      let url = this._get(file, 'response.data.link', '');
      if (url) {
        file.url = url;
      }
      const fileType = this.getFileType(file.url);
      if (['doc', 'docx', 'xlsx', 'xls'].includes(fileType)) {
        this.previewVisible = true;
        this.fileUrl = file.url;
        this.fileType = fileType;
        return;
      }
      if (file.url.indexOf('pdf') != -1) {
        downLoad({ link: file.url }).then(
          (res) => {
            let fileURL = null;
            var blob = new Blob([res.data], { type: 'application/pdf' });
            if (window.createObjectURL != undefined) {
              // basic
              fileURL = window.createObjectURL(blob);
            } else if (window.webkitURL != undefined) {
              // webkit or chrome
              try {
                fileURL = window.webkitURL.createObjectURL(blob);
              } catch (error) {
                console.log(error);
              }
            } else if (window.URL != undefined) {
              // mozilla(firefox)
              try {
                fileURL = window.URL.createObjectURL(blob);
              } catch (error) {
                console.log(error);
              }
            }
            this.pdfUrl = '/pdf/web/viewer.html?file=' + encodeURIComponent(fileURL);
            this.showEsopDialog = true;
          },
          (error) => {}
        );
      } else {
        if (this.isImageFile(url || file.url)) {
          this.$ImagePreview([{ url: url ? url : file.url }], 0, {
            closeOnClickModal: false
          });
        } else {
          window.open(url || file.url);
        }
      }
    },
    isImageFile(filename) {
      let ext = filename.split('.').pop().toLowerCase();
      return ['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(ext);
    },
    async blobToJson(blob) {
      return new Promise((resolve, reject) => {
        blob.arrayBuffer().then(
          async (arrayBuffer) => {
            resolve(JSON.parse(Buffer.from(arrayBuffer).toString('utf-8')));
          },
          (error) => {
            reject(error);
          }
        );
      });
    },
    rowSave(row, done, loading) {
      try {
        const qmsInspectionExceptionVoList = this.basicInfoForm.qmsInspectionExceptionVoList || [];
        const tableData = {
          ngFailureName: row.failureName,
          ngMainCauseName: row.$mainType,
          ngSubCauseName: row.$subType ? row.$subType.split('|').join(',') : '',
          faultDescription: row.faultDescription,
          improvementMeasure: row.improvementMeasure,
          remark: row.remark,
          qmsInspectionExceptionDetailList: this.getQmsInspectionExceptionDetailList(row),
          qmsInspectionAttachmentList: this.qmsInspectionAttachmentList
        };
        qmsInspectionExceptionVoList.push(tableData);
        this.$set(this.basicInfoForm, 'qmsInspectionExceptionVoList', qmsInspectionExceptionVoList);
        this.qmsInspectionAttachmentList = [];
      } catch (e) {
        console.warn(e);
      }
      done();
    },
    getQmsInspectionExceptionDetailList(row) {
      // 现象 构造
      const failureObj = {
        dictType: 'FAILURE',
        subType: null,
        dictId: row.failureId,
        dictCode: row.failureCode,
        dictName: row.failureName,
        remark: row.remark
      };
      //大类
      const mianTypeObj = {
        dictType: 'CAUSE',
        subType: 'MAIN',
        dictId: row.mainType,
        dictCode: this._find(this.mainTypeList, { id: row.mainType }).code,
        dictName: row.$mainType,
        remark: row.remark
      };
      // 小类
      let subTypeList = [];
      if (row.subType.length) {
        subTypeList = row.subType.map((item, index) => ({
          dictType: 'CAUSE',
          subType: 'SUB',
          dictId: item,
          dictCode: this._find(this.subTypeList, { id: item }).code,
          dictName: row.$subType.split('|')[index],
          remark: row.remark
        }));
      }
      return [failureObj, mianTypeObj, ...subTypeList];
    },
    rowUpdate(row, index, done, loading) {
      const qmsInspectionExceptionVoList = this.basicInfoForm.qmsInspectionExceptionVoList || [];
      const tableData = {
        ngFailureName: row.failureName,
        ngMainCauseName: row.$mainType,
        ngSubCauseName: row.$subType.split('|').join(','),
        faultDescription: row.faultDescription,
        improvementMeasure: row.improvementMeasure,
        remark: row.remark,
        qmsInspectionExceptionDetailList: this.getQmsInspectionExceptionDetailList(row),
        qmsInspectionAttachmentList: this.qmsInspectionAttachmentList
      };
      qmsInspectionExceptionVoList.splice(index, 1, tableData);
      this.$set(this.basicInfoForm, 'qmsInspectionExceptionVoList', qmsInspectionExceptionVoList);
      this.qmsInspectionAttachmentList = [];
      done();
    },
    rowDel(row, index) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const qmsInspectionExceptionVoList = this.basicInfoForm.qmsInspectionExceptionVoList;
        qmsInspectionExceptionVoList.splice(index, 1);
        this.$set(this.basicInfoForm, 'qmsInspectionExceptionVoList', qmsInspectionExceptionVoList);
      });
    },
    getSelectedRows(rowData) {
      switch (this.modalName) {
        case 'failureModal':
          this.qmsInspectionExceptionVoListForm.failureId = rowData.id;
          this.qmsInspectionExceptionVoListForm.failureCode = rowData.code;
          this.qmsInspectionExceptionVoListForm.failureName = rowData.name;
          break;
        case 'userModal':
          this.basicInfoForm.examineBy = rowData.id;
          this.basicInfoForm.examineByName = rowData.realName;
          break;
        default:
          break;
      }
    },
    openFailureCommonModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'failureModal';
      this.tableOption = {
        modalTitle: '不良现象（双击进行选择）',
        url: '/api/mes-product/mro-dict/page?dictType=BAD_PHENOMENON',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '不良代码',
            prop: 'code',
            search: true
          },
          {
            label: '不良现象描述',
            prop: 'name'
          }
        ]
      };
    },
    openUserCommonModal() {
      this.modalName = 'userModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择检验人员信息（双击进行选择）',
        url: '/api/blade-system/user/page',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '用户姓名',
            prop: 'realName',
            search: true,
            searchLabelWidth: 150,
            searchSpan: 8
          },
          {
            label: '所属部门',
            prop: 'deptName',
            searchLabelWidth: 150,
            searchSpan: 8
          },
          {
            label: '职务',
            prop: 'postName'
          },
          {
            label: '用户平台',
            prop: 'userTypeName'
          }
        ]
      };
    }
  }
};
</script>

<style lang="scss" scoped>
.titleIcon {
  display: flex;
  align-items: center;
}

.title-result {
  display: flex;
  justify-content: space-between;
  .title {
    display: flex;
    align-items: center;
  }
  .reslut-btn-group {
    margin-right: 8px;
  }
}

.dialog-content {
  height: calc(100vh - 180px);
  overflow-y: scroll;
  overflow-x: hidden;
}
.dialog-footer {
  height: 50px;
}
h4 {
  margin-top: 4px;
  margin-bottom: 4px;
}
.download-box {
  .dowload-item {
    margin: 4px 8px;
    color: #007dff;
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none;
    &:hover {
      cursor: pointer;
    }
  }
}

.dialog-title {
  position: relative;
  .title {
    display: inline-block;
  }
  .fullscreen-icon {
    position: absolute;
    right: 20px;
    cursor: pointer;
    display: inline-block;
    font-size: 14px;
    color: #909399;
    &:hover {
      color: #0a84ff;
    }
  }
}

.fullscreen {
  ::v-deep .el-dialog {
    width: 100%;
    margin: 0 !important;
    margin-top: 0vh !important;
  }
}
.no_fullScreen {
  ::v-deep.el-dialog {
    width: 50%;
    margin-top: 5vh !important;
  }
}
</style>
